package com.csm.yygh.hosp.controller;

import com.csm.yygh.common.result.Result;
import com.csm.yygh.hosp.service.HospitalSetService;
import com.csm.yygh.model.hosp.HospitalSet;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 86166
 */
@Slf4j
@Api(tags = "医院设置管理")
@RestController
@RequestMapping("/admin/hosp/hospitalSet")
public class HospitalSetController {

    /**
     * 注入service
     */
    @Autowired
    private HospitalSetService hospitalSetService;

    /**
     * 查询医院所有信息
     * @return 返回医院信息
     */
    @ApiOperation("查询医院设置所有数据")
    @GetMapping("findAll")
    public Result findAll() {
        List<HospitalSet> list = hospitalSetService.list();
        System.out.println(list);
        Result<List<HospitalSet>> ok = Result.ok(list);
        return ok;
    }

    /**
     * 逻辑删除
     * @param id 传入的id
     * @return 查看是否成功
     */
    @ApiOperation("逻辑删除医院设置信息")
    @DeleteMapping("{id}")
    public Result delete(@PathVariable("id") int id) {
        boolean remove = hospitalSetService.removeById(id);
        if (remove == true) {
            return Result.ok();
        }
        else {
            return Result.fail();
        }

    }

    @GetMapping("/")
    public String po() {
        return "asdad";
    }
}
